package biz.ezcom.design.pattern.prototype;

import java.util.Date;

/**
 * 深克隆
 */
public class PrototypeDeep implements Cloneable {

	private String name;
	private Date date;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@Override
	public Object clone() {
		PrototypeDeep clone = new PrototypeDeep();
		clone.setName(this.getName());//String 可看作原始类型
		Date date = new Date(this.getDate().getTime());//引用类型重新 new
		clone.setDate(date);
		return clone;
	}
}
